import sys
from functools import wraps


def loop(func):
    @wraps(func)
    def inner(*args, **kwargs) -> None:
        while True:    
            func(*args, **kwargs)
    return inner



def exception(func):
    @wraps(func)
    def inner(*args, **kwargs):
        try:
            res = func(*args, **kwargs)
        except TimeoutError as ex:
            print(ex)
            return False
        except KeyboardInterrupt as ex:
            print(ex)
            sys.exit(0)
        except Exception as ex:
            print(ex)
            return False
        else:
            return res
    return inner
